package com.bootdo.hjh.dao;

import com.bootdo.hjh.domain.SmsVerification;
import com.bootdo.hjh.domain.SmsVerificationExample;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.session.RowBounds;

import java.util.List;

public interface SmsVerificationMapper {
    int countByExample(SmsVerificationExample example);

    int deleteByExample(SmsVerificationExample example);

    int deleteByPrimaryKey(Integer id);

    int insert(SmsVerification record);

    int insertSelective(SmsVerification record);

    List<SmsVerification> selectByExampleWithRowbounds(SmsVerificationExample example, RowBounds rowBounds);

    List<SmsVerification> selectByExample(SmsVerificationExample example);

    SmsVerification selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") SmsVerification record, @Param("example") SmsVerificationExample example);

    int updateByExample(@Param("record") SmsVerification record, @Param("example") SmsVerificationExample example);

    int updateByPrimaryKeySelective(SmsVerification record);

    int updateByPrimaryKey(SmsVerification record);

    Long sumByExample(SmsVerificationExample example);

    void batchInsert(@Param("items") List<SmsVerification> items);

    /**
     * 最近一条短信验证码
     */
    @Select("select * from sms_verification where mobile=#{mobile} order by id desc limit 1")
    SmsVerification lastSmsVerification(@Param("mobile") String mobile);

    @Update("update sms_verification set is_used = 1 where id = #{id}")
    int usedSmsVerification(@Param("id") Integer id);
}